package color.koitq.picker.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.animation.SlideInLeftAnimation;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import color.koitq.picker.R;
import color.koitq.picker.entity.Tab4Model;

public class Tab4Adapter extends BaseQuickAdapter<Tab4Model, BaseViewHolder> {
    private Tab4SubAdapter mAdapter;
    private Tab4ItemClickListener mClickListener;

    public Tab4Adapter setClickListener(Tab4ItemClickListener clickListener) {
        mClickListener = clickListener;
        return this;
    }

    public Tab4Adapter() {
        super(R.layout.item_tab4);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, Tab4Model tab4Model) {
        baseViewHolder.setText(R.id.title,tab4Model.title);
        RecyclerView  list = baseViewHolder.getView(R.id.list);
        mAdapter=new Tab4SubAdapter();
        mAdapter.setNewInstance(tab4Model.colors);
        list.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.HORIZONTAL,false));
        list.setAdapter(mAdapter);
        baseViewHolder.getView(R.id.listClick).setOnClickListener(v -> {
            if (mClickListener != null) {
                mClickListener.click(tab4Model);
            }
        });
        baseViewHolder.getView(R.id.delete).setOnClickListener(v -> {
            if (mClickListener != null) {
                mClickListener.delete(tab4Model);
            }
        });

    }
    public interface Tab4ItemClickListener{
        void click(Tab4Model model);
        void delete(Tab4Model model);
    }
}
